package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.vo.CategoryVo;
import com.spzx.product.api.factory.RemoteCategoryFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

@FeignClient(contextId = "remoteCategoryService",name = ServiceNameConstants.PRODUCT_SERVICE,fallbackFactory = RemoteCategoryFallbackFactory.class)
public interface RemoteCategoryService {

    //声明远程调用接口：
    //OpenFeign远程调用，如何携带请求头信息。
    @GetMapping("/category/getCategoryOne")
    public R<List<CategoryVo>> getCategoryOne(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 获取三级分类(树结构)
     * @param source
     * @return
     */
    @GetMapping(value = "/category/tree")
    public R<List<CategoryVo> > tree(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
